package com.ys.timer;

import com.ys.service.report.ReFinanceExamineService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;

import java.text.SimpleDateFormat;
import java.util.Calendar;

@Controller
public class TimerReFinanceExamineDaily {
	private static final Logger logger = LoggerFactory.getLogger(TimerReFinanceExamineDaily.class);

	@Autowired
	private ReFinanceExamineService reFinanceExamineService;

	//每天23:59:59点执行，统计财务核账表
	@Scheduled(cron = "59 59 23 * * * ")
	public void addReFinanceExamineDaily() {
		try {
			logger.info("***********定时统计财务核账表开始***********");
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			//获取当前时间日期
			Calendar calendar = Calendar.getInstance();
			String nowDate = sdf.format(calendar.getTime());
			//开始定时任务
			reFinanceExamineService.countReFinanceExamine(nowDate,"23:59:59");
			logger.info("***********定时统计财务核账表完成***********");
		}catch (Exception e){
			logger.error("定时统计财务核账表出错：",e.getMessage(),e);
		}
	}



	
}
